<?php
include("include/config.inc.php");
if(isset($_POST['submit']))
{
	$name              = isset($_POST['name']) ? $_POST['name'] : "";
	$typeOfCompany     = isset($_POST['typeOfCompany']) ? $_POST['typeOfCompany'] : "";
	$address           = isset($_POST['address']) ? $_POST['address'] : "";
	$country           = isset($_POST['country']) ? $_POST['country'] : "";
	$phoneNo           = isset($_POST['phoneNo']) ? $_POST['phoneNo'] : "";
	$email             = isset($_POST['email']) ? $_POST['email'] : "";
	$alternativeEmail  = isset($_POST['alternativeEmail']) ? $_POST['alternativeEmail'] : "";
	$referedBy         = isset($_POST['referedBy']) ? $_POST['referedBy'] : "";
	$web               = isset($_POST['web']) ? $_POST['web'] : "";
	$company           =implode(',',$typeOfCompany);
	
	$insertContact = "INSERT INTO contactus (typeOfCompany,name,address,country,phoneNo,email,alternativeEmail,referedBy,web,dateAndTime)
	                    VALUES('".$company."','".$name."','".$address."','".$country."','".$phoneNo."','".$email."','".$alternativeEmail."','".$referedBy."','".$web."','".date("Y-m-d H:i:s")."')";
	$insertContactRes = mysql_query($insertContact);
	if(!$insertContactRes)
	{
		die("Insert Query Not Insertd :" .mysql_error());
	}
	else
	{
		header("Location:contactUs.php");
	}
	
	$to = "$email $alternativeEmail"; 
	$subject = $name;
  $message = '<html><body>';
  $message =  "<table rules='all' class='border_01' height='300' width='400' align='center'>
	             <tr><td align='center' colspan='2'><h1>Inquiry</h1> </td> </tr>
	              <tr><td><b> Name :              </b></td> <td>".$name."</td> </tr>
	              <tr><td><b> Type Of Company :     </b></td> <td>".$company."</td> </tr>
	              <tr><td><b> Address :           </b></td> <td>".$address."</td> </tr>
	              <tr><td><b> Country :           </b></td> <td>".$country."</td> </tr>
	              <tr><td><b> PhoneNo :           </b></td> <td>".$phoneNo."</td> </tr>
	              <tr><td><b> Email :             </b></td> <td>".$email."</td> </tr>
	              <tr><td><b> Alternative Email :  </b></td> <td>".$alternativeEmail."</td> </tr>
	              <tr><td><b> ReferedBy :         </b></td> <td>".$referedBy."</td> </tr>
	              <tr><td><b> Web :               </b></td> <td>".$web."</td> </tr>
	               <tr><td align='center' colspan='2'></td> </tr>
	           </table>";
	$message .= "</body></html>";                        
	"<br> Email  :  ".$from = "";
	$headers = "From:" . $from;
	$headers .= "info@stallionenterprise.in\r\n";
	mail($to,$subject,$message,$headers);
	
}
include("bottom.php");
$smarty->display("contactUs.tpl");
?>